package ng.graphics;

import java.awt.Dimension;
import java.awt.image.BufferedImage;

public class Animation {
	private FrameBuffer frames;
	private int currentFrame = 0;
	
	private int delay = 1;
	private int currentDelay = 0;
	
	public Animation(FrameBuffer f, int d) {
		this.frames = f;
		this.delay = d;
	}
	
	public BufferedImage getImage() {
		return frames.getFrame(currentFrame);
	}
	
	public Dimension getDimension() {
		return frames.getDimension(currentFrame);
	}
	public void tick(){
		currentDelay++;
		if(currentDelay == delay){
			currentDelay = 0;
			currentFrame++;
			if(currentFrame >= frames.getNumberOfFrames())
				currentFrame = 0;
		}
	};
}
